import Mock from "mockjs";

Mock.Random.extend({
    phone: function() {
        var phonePrefixs = ["132", "135", "189"]; // 自己写前缀哈
        return this.pick(phonePrefixs) + Mock.mock(/\d{8}/); //Number()
    },
});

// 定义数据类型
let data = Mock.mock({
    // 20条数据
    "data|95": [{
        "num|+1": 1,
        name: "@cname",
        "zt|1": ["1", ""],
        // 手机号
        phone: "@phone",
        // 方式
        "methods|1": ["全职+课时责任制", "兼职+课时责任制", "兼职+上课总人数"],
        //时间
        updataTime: "@date(2021-MM-dd hh:mm:ss)",
        joinTime: "@date(2020-MM-dd hh:mm:ss)",
        //商品名称
        cjpeople: "管理员",
        flag: "",
        //商品地址
    }, ],
});

class TeacherService {
    getDate() {
        return Promise.resolve({
            data,
        });
    }
    delete(id) {
        data.data = data.data.filter((item) => item.num !== id);
        return Promise.resolve(data);
    }
    edit(id) {
        let obj = {};
        data.data = data.data.filter((item) => {
            if (item.num == id) {
                obj = item;
            }
            return data;
        });
        return Promise.resolve(obj);
    }
}

const teacher = new TeacherService();
export default teacher;